package com.grm.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.ldap.core.LdapTemplate;
import org.springframework.ldap.core.support.LdapContextSource;

@Slf4j
@Configuration
public class LdapConfig {
    @Bean
    public LdapContextSource ldapContextSource(){
        LdapContextSource source = new LdapContextSource();
        source.setUrl("ldap://xxx:389/OU=xxx,DC=home,DC=com");
        source.setPassword("xxx");
        source.setUserDn("CN=xxx,OU=xxx,DC=home,DC=com");
        return source;
    }

    @Bean
    public LdapTemplate ldapTemplate(){
        return new LdapTemplate(ldapContextSource());
    }
}

